from rest_framework import serializers
from main.models import Forks, Articels, ContentImages, Remarks


class ForksSerializer(serializers.ModelSerializer):
    class Meta:
        model = Forks
        fields = ["pk", "forkName", "add_time"]
        read_only_fields = ["add_time"]


class ForkNameForaArticel(serializers.ModelSerializer):
    class Meta:
        model = Forks
        fields = ["forkName","pk"]


class ArticelsSerializer_Get(serializers.ModelSerializer):
    forkby = ForkNameForaArticel()

    class Meta:
        model = Articels
        fields = ["pk", "title", "forkby", "content", "add_time"]
        read_only_fields = ["pk", "title", "forkby", "content", "add_time"]


class ArticelsSerializer_Post(serializers.ModelSerializer):
    class Meta:
        model = Articels
        fields = ["pk", "title", "forkby", "content", "add_time"]
        read_only_fields = ["add_time"]


class ContentImagesSerializer(serializers.ModelSerializer):
    class Meta:
        model = ContentImages
        fields = ["pk", "owner", "iamges", "add_time"]
        read_only_fields = ["add_time"]


class RemarksSerializer(serializers.ModelSerializer):
    class Meta:
        model = Remarks
        fields = ["pk", "title", "content", "add_time"]
        read_only_fields = ["add_time"]
